<template>
	<view>
		<u-divider>富文本编辑器</u-divider>
		<editor id="editor" class="ql-container" :placeholder="placeholder" @input="handleInput" @ready="onEditorReady">
		</editor>
	</view>
</template>

<script>
	import mixin from "./mixin";

	export default {
		mixins: [mixin],
		data() {
			return {
				placeholder: '开始输入...'
			}
		},
		methods: {
			handleInput(obj) {
				this.component.content = obj.detail.html
				this.handleUpdate(this.component)
			},
			onEditorReady() {
				uni.createSelectorQuery().select('#editor').context((res) => {
					this.editorCtx = res.context
					this.editorCtx.setContents({
						html: this.component.content
					})
				}).exec()

			},
			undo() {
				this.editorCtx.undo()
			}
		}
	}
</script>

<style>
</style>
